package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.UserEcologyCastUpperLimitDetails;
import com.sc.nft.entity.vo.ecology.AdminUserEcologyReforgeUpperLimitPageVO;
import com.sc.nft.entity.vo.ecology.UserEcologyReforgeUpperLimitDetailsVO;
import com.sc.nft.enums.UserEcologyCastUpperLimitDetailsTypeEnum;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.UserEcologyReforgeUpperLimitDetails;
import com.sc.nft.mapper.UserEcologyReforgeUpperLimitDetailsMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * 生态-重铸上限记录明细表(sc_user_ecology_reforge_upper_limit_details)数据DAO
 *
 * @author Sun
 * @since 2024-06-07 09:04:10
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class UserEcologyReforgeUpperLimitDetailsDao extends ServiceImpl<UserEcologyReforgeUpperLimitDetailsMapper, UserEcologyReforgeUpperLimitDetails> {

    public Page<UserEcologyReforgeUpperLimitDetailsVO> getUserEcologyReforgeUpperLimitDetails(Long userId, Long collectionId, Integer pageNo, Integer pageSize) {
        return baseMapper.getUserEcologyReforgeUpperLimitDetails(new Page<>(pageNo, pageSize), userId,collectionId);
    }

    public Page<AdminUserEcologyReforgeUpperLimitPageVO> getUserEcologyReforgeUpperLimitPage(Long userId, Long collectionId, Date beginTime, Date endTime, Integer pageNo, Integer pageSize) {
        return baseMapper.getUserEcologyReforgeUpperLimitPage(new Page<>(pageNo, pageSize), userId, collectionId, beginTime, endTime);
    }

    /**
     * 批量入库
     *
     * @param list
     * @return
     */
    public Integer saveList(List<UserEcologyReforgeUpperLimitDetails> list){
        return baseMapper.saveList(list);
    }

    public List<UserEcologyReforgeUpperLimitDetails> getByUserRecordsIds(List<Long> userRecordsIds) {
        LambdaQueryWrapper<UserEcologyReforgeUpperLimitDetails> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(UserEcologyReforgeUpperLimitDetails::getUserRecordsId, userRecordsIds);
        wrapper.eq(UserEcologyReforgeUpperLimitDetails::getType, UserEcologyCastUpperLimitDetailsTypeEnum.SMELTING);
        return baseMapper.selectList(wrapper);
    }
}